{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6301516b-a3fa-48e2-a95f-0f79903a6cdd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import unittest\n",
    "from decimal import Decimal\n",
    "import age \n",
    "\n",
    "resultHandler = age.newResultHandler()\n",
    "    \n",
    "def evalExp(exp):\n",
    "    value = resultHandler.parse(exp) \n",
    "    print(type(value), \"|\", exp, \" --> \" ,value )\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "adf14fe9-692c-4701-86d4-8c84fd53d966",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "mapStr = '{\"name\": \"Smith\", \"num\":123, \"yn\":true, \"bigInt\":123456789123456789123456789123456789::numeric}' \n",
    "arrStr =  '[\"name\", \"Smith\", \"num\", 123, \"yn\", true, 123456789123456789123456789123456789.8888::numeric]' \n",
    "strStr =  '\"abcd\"' \n",
    "intStr =  '1234' \n",
    "floatStr =  '1234.56789' \n",
    "numericStr1 =  '12345678901234567890123456789123456789.789::numeric' \n",
    "numericStr2 =  '12345678901234567890123456789123456789::numeric' \n",
    "boolStr = 'true' \n",
    "\n",
    "evalExp(mapStr)\n",
    "evalExp(arrStr)\n",
    "evalExp(strStr)\n",
    "evalExp(intStr)\n",
    "evalExp(floatStr)\n",
    "evalExp(numericStr1)\n",
    "evalExp(numericStr2)\n",
    "evalExp(boolStr)\n",
    "\n",
    "evalExp('-6.45161290322581e+46') \n",
    "evalExp('-123456789.99::numeric') \n",
    "evalExp('-6.45161290322581e+46::numeric') \n",
    "evalExp('1234') \n",
    "evalExp('NaN') \n",
    "evalExp('-Infinity') \n",
    "evalExp('Infinity') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8881804e-d71d-4704-b74c-376ed55be808",
   "metadata": {},
   "outputs": [],
   "source": [
    " vertexExp = '''{\"id\": 2251799813685425, \"label\": \"Person\", \n",
    "    \"properties\": {\"name\": \"Smith\", \"numInt\":123, \"numFloat\": 384.23424, \n",
    "    \"bigInt\":123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789::numeric, \n",
    "    \"bigFloat\":123456789123456789123456789123456789.12345::numeric, \n",
    "    \"yn\":true, \"nullVal\": null}}::vertex'''\n",
    "\n",
    "vertex = age.parseAgeValue(vertexExp)\n",
    "print(type(vertex.id), vertex.id)\n",
    "print(type(vertex.label), vertex.label)\n",
    "print(type(vertex[\"name\"]), vertex[\"name\"])\n",
    "print(type(vertex[\"numInt\"]), vertex[\"numInt\"])\n",
    "print(type(vertex[\"numFloat\"]), vertex[\"numFloat\"])\n",
    "print(type(vertex[\"bigInt\"]), vertex[\"bigInt\"])\n",
    "print(type(vertex[\"bigFloat\"]), vertex[\"bigFloat\"])\n",
    "print(type(vertex[\"yn\"]), vertex[\"yn\"])\n",
    "print(type(vertex[\"nullVal\"]), vertex[\"nullVal\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0a70e467-9587-4eb7-b97d-895223009bcc",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "pathExp = '''[{\"id\": 2251799813685425, \"label\": \"Person\", \"properties\": {\"name\": \"Smith\"}}::vertex, \n",
    "    {\"id\": 2533274790396576, \"label\": \"workWith\", \"end_id\": 2251799813685425, \"start_id\": 2251799813685424, \n",
    "        \"properties\": {\"weight\": 3, \"bigFloat\":123456789123456789123456789.12345::numeric}}::edge, \n",
    "    {\"id\": 2251799813685424, \"label\": \"Person\", \"properties\": {\"name\": \"Joe\"}}::vertex]::path'''\n",
    "\n",
    "path = age.parseAgeValue(pathExp)\n",
    "vertexStart = path[0]\n",
    "edge = path[1]\n",
    "vertexEnd = path[2]\n",
    "\n",
    "print(type(vertexStart.id), vertexStart.id)\n",
    "print(type(vertexStart.label), vertexStart.label)\n",
    "print(type(vertexStart[\"name\"]), vertexStart[\"name\"])\n",
    "\n",
    "print(type(edge.id), edge.id)\n",
    "print(type(edge.label), edge.label)\n",
    "print(type(edge[\"weight\"]), edge[\"weight\"])\n",
    "print(type(edge[\"bigFloat\"]), edge[\"bigFloat\"])\n",
    "\n",
    "print(type(vertexEnd.id), vertexEnd.id)\n",
    "print(type(vertexEnd.label), vertexEnd.label)\n",
    "print(type(vertexEnd[\"name\"]), vertexEnd[\"name\"])\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "62b7273f-ac6c-4dec-af7e-0467daa140f4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
